---
title: OLEDBError Object (Excel)
keywords: vbaxl10.chm653072
f1_keywords:
- vbaxl10.chm653072
ms.prod: excel
api_name:
- Excel.OLEDBError
ms.assetid: 6bcbf721-f2c8-f784-361b-e1a298bb2ecb
ms.date: 06/08/2017
---


# OLEDBError Object (Excel)

Represents an OLE DB error returned by the most recent OLE DB query.


## Remarks

 The **OLEDBError** object is a member of the **[OLEDBErrors](oledberrors-object-excel.md)** collection. If the specified OLE DB query runs without error, the **OLEDBErrors** collection is empty. The errors in the collection are indexed in the order in which they're generated by the OLE DB provider.


## Example

Use  **[OLEDBErrors](application-odbcerrors-property-excel.md)** ( _index_ ), where _index_ is the index number of the OLE DB error, to return a single **OLEDBError** object. The following example displays the error description and the **[SqlState](oledberror-sqlstate-property-excel.md)** property's value for the first error returned by the most recent OLE DB query.


```vb
Set objEr = Application.OLEDBErrors(1) 
MsgBox "The following error occurred:" &; _ 
 objEr.ErrorString &; " : " &; objEr.SqlState
```


## See also


#### Other resources


[Excel Object Model Reference](http://msdn.microsoft.com/library/11ea8598-8a20-92d5-f98b-0da04263bf2c%28Office.15%29.aspx)


